<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Asset extends MX_Controller {
    
  function __construct() {  
    $this->load->library('template');
    $this->load->library('form_eksternal');
    $this->load->library('global_models');
    $this->load->library('PHPExcel');
    $this->load->library('encrypt');
    $this->load->helper('path');
    $this->load->helper('url');
    $this->load->model('asset/mmaster');
    $this->load->library('parser');
    $this->load->library('session');
    $this->load->library('form_validation');
    $this->load->library('pagination');
    $this->load->library('manimage');
    $this->load->library('upload');
    $this->load->model('dev_checklist/mdev_checklist');
    $this->menu = $this->cek();
  }
  public function index($status = 0, $pesan = ""){
    $gudang = $this->global_models->get("m_asset_gudang");
    $this->template->build('asset',
      array(
            'url'         => base_url()."themes/srabon/",
            'title_table' => "Asset",
            'gudang'      => $gudang
          ));
    $this->template
      ->set_layout('default')
      ->build('asset');
  }
  public function product_in_gudang($id_gudang = 0){
    $gudang = $this->global_models->get("m_asset_gudang", array("id_asset_gudang" => $id_gudang));
    $query = "
      SELECT A.id_asset, sum(A.qty) AS qty, B.name, B.kode, A.id_asset_gudang
      FROM d_asset_record_items_gudang AS A
      LEFT JOIN m_asset AS B ON A.id_asset = B.id_asset
      WHERE A.id_asset_gudang = {$id_gudang} AND A.status = 2
      GROUP BY A.id_asset
    ";
    $data = $this->global_models->get_query($query);
    $this->template->build('product-in-gudang',
      array(
            'url'         => base_url()."themes/srabon/",
            'title_table' => "Products at ".$gudang[0]->name,
            'data'        => $data,
          ));
    $this->template
      ->set_layout('default')
      ->build('product-in-gudang');
  }
  public function detail_items_in_gudang($id_asset, $id_gudang){
    $asset = $this->global_models->get("m_asset", array("id_asset" => $id_asset));
    $data = $this->global_models->get("d_asset_record_items_gudang", array("id_asset_gudang" => $id_gudang, "id_asset" => $id_asset, 'status' => 2));
    $this->template->build('detail-record-items',
      array(
            'url'         => base_url()."themes/srabon/",
            'title_table' => "Detail Log Item ".$asset[0]->name." ".$asset[0]->kode,
            'data'        => $data,
          ));
    $this->template
      ->set_layout('default')
      ->build('detail-record-items');
  }
  public function add_asset($id = 0){
    
    if($this->input->post(NULL)){
      $pst = $this->input->post(NULL);
      if($pst['id_detail']){
        $kirim = array(
            "name"              => $pst['name'],
            "kode"              => $pst['kode'],
            "id_asset_gudang"   => $pst['id_asset_gudang'],
            "id_supplier"       => $pst['id_supplier'],
            "tanggal"           => $pst['tanggal'],
            "note"              => $pst['note'],
            "update_by_users"   => $this->session->userdata('id')
        );
        $cek_update = $this->global_models->update("d_asset_in", array("id_asset_in" => $pst['id_detail']), $kirim);
        
//        delete
        $this->global_models->update("d_asset_in_items", array("id_asset_in" => $pst['id_detail']), array("status" => 1));
        $this->global_models->update("d_asset_record_items_gudang", array("id_asset_in" => $pst['id_detail']), array("status" => 1));
        foreach ($pst['id_asset'] as $k_asset => $asset) {
          $kirim_items = array(
              "id_asset"        => $asset,
              "id_asset_in"     => $pst['id_detail'],
              "qty"             => $pst['qty'][$k_asset],
              "status"          => 2,
              "create_by_users" => $this->session->userdata('id'),
              "create_date"     => date("Y-m-d"),
              "id_asset_in_items" => $pst['id_asset_in_items'][$k_asset],
          );
          $else_kirim_items = array(
              "id_asset"        => $asset,
              "qty"             => $pst['qty'][$k_asset],
              "status"          => 2,
              "update_by_users" => $this->session->userdata('id'),
          );
          $id_asset_in_items = $this->global_models->update_duplicate("d_asset_in_items", $kirim_items, $else_kirim_items);
          
          $record = array(
              "id_asset_gudang"         => $pst['id_asset_gudang'],
              "id_asset"                => $asset,
              "id_asset_in"             => $pst['id_detail'],
              "id_asset_in_items"       => $id_asset_in_items,
              "tanggal"                 => $pst['tanggal'],
              "qty"                     => $pst['qty'][$k_asset],
              "status"                  => 2,
              "create_by_users"         => $this->session->userdata('id'),
              "create_date"             => date("Y-m-d"),
              "id_asset_record_items_gudang" => $pst['id_asset_record_items_gudang'][$k_asset],
          );
          $else_record = array(
              "id_asset_gudang"         => $pst['id_asset_gudang'],
              "id_asset"                => $asset,
              "id_asset_in_items"       => $id_asset_in_items,
              "tanggal"                 => $pst['tanggal'],
              "qty"                     => $pst['qty'][$k_asset],
              "status"                  => 2,
              "update_by_users"         => $this->session->userdata('id'),
          );
          $this->global_models->update_duplicate("d_asset_record_items_gudang", $record, $else_record);
        }
        if($cek_update)
          redirect ('asset/index/1/Berhasil');
        else
          redirect ('asset/index/2/Gagal');
      }
      else{
        $kirim = array(
            "name"                  => $pst['name'],
            "kode"                  => $pst['kode'],
            "id_asset_gudang"       => $pst['id_asset_gudang'],
            "id_supplier"           => $pst['id_supplier'],
            "tanggal"               => $pst['tanggal'],
            "note"                  => $pst['note'],
            "create_by_users"       => $this->session->userdata('id'),
            "create_date"           => date("Y-m-d")
        );
        $id_asset_in = $this->global_models->insert("d_asset_in", $kirim);
        foreach ($pst['id_asset'] as $k_asset => $asset) {
          $kirim_items = array(
              "id_asset_in"     => $id_asset_in,
              "id_asset"        => $asset,
              "qty"             => $pst['qty'][$k_asset],
              "status"          => 2,
              "create_by_users" => $this->session->userdata('id'),
              "create_date"     => date('Y-m-d')
          );
          $id_asset_in_items = $this->global_models->insert("d_asset_in_items", $kirim_items);
          $record = array(
              "id_asset_gudang"         => $pst['id_asset_gudang'],
              "id_asset"                => $asset,
              "id_asset_in"             => $id_asset_in,
              "id_asset_in_items"       => $id_asset_in_items,
              "tanggal"                 => $pst['tanggal'],
              "qty"                     => $pst['qty'][$k_asset],
              "status"                  => 2,
              "create_by_users"         => $this->session->userdata('id'),
              "create_date"             => date('Y-m-d')
          );
          $id_asset_record_items_gudang = $this->global_models->insert("d_asset_record_items_gudang", $record);
        }
        if($id_asset_in)
          redirect ('asset/index/1/Berhasil');
        else
          redirect ('asset/index/2/Gagal');
      }
    }
    
    if($id > 0){
      
      $detail = $this->global_models->get("d_asset_in", array("id_asset_in" => $id));

      $items = $this->global_models->get_query("
        SELECT A.*, B.name
        FROM d_asset_in_items AS A
        LEFT JOIN m_asset AS B ON A.id_asset = B.id_asset
        WHERE A.id_asset_in = {$id} AND status = 2
        ");
      $k = 1;
      foreach($items as $itm){
//          $this->debug($itm, true);
        $isi[] = array(
          $this->form_eksternal->form_autocomplate("asset[]", "id_asset[]", "asset_".$k, "id_asset_".$k, site_url("asset/auto-asset"), $itm->name, $itm->id_asset, "", "", "id_asset_in_items[]", $itm->id_asset_in_items),
          $this->form_eksternal->form_input('qty[]', $itm->qty, 'class="span3" onblur="total('.$k.')" id="qty_'.$k.'" '.$diabled),
          $this->form_eksternal->form_input('id_asset_in_items[]', $itm->id_asset_in_items, 'style="display: none;"'),
          $this->form_eksternal->form_input('id_asset_record_items_gudang[]', $this->global_models->get_field("d_asset_record_items_gudang", 'id_asset_record_items_gudang', array("id_asset_in_items" => $itm->id_asset_in_items)), 'style="display: none;"'),
        );
        $tr[] = "tr_".$k;
        $k++;
      }
    }
    else{
      $isi[1] = array(
        $this->form_eksternal->form_autocomplate("asset[]", "id_asset[]", "asset_1", "id_asset_1", site_url("asset/auto-asset"), "", 0),
        $this->form_eksternal->form_input('qty[]', $value = '', 'class="span3" id="qty_1"'),
      );
      $tr[1] = "tr_1";
    }
    $this->template->build('add-asset',
      array(
            'url'         => base_url()."themes/srabon/",
            'title_table' => "Create Asset",
            'isi'         => $isi,
            'tr'          => $tr,
            'detail'      => $detail
          ));
    $this->template
      ->set_layout('default')
      ->build('add-asset');
  }
  
  public function auto_asset(){
    if (empty($_GET['term'])) exit ;
    $q = strtolower($_GET["term"]);
    if (get_magic_quotes_gpc()) $q = stripslashes($q);
    $items = $this->mmaster->auto_asset($q);
    $result = array();
    foreach ($items as $key=>$value) {
      if (strpos(strtolower($key), $q) !== false) {
        array_push($result, array("id"=>$value, "label"=>$key, "value" => strip_tags($key)));
      }
      if (count($result) > 11)
        break;
    }
    echo json_encode($result);
    die;
  }
  public function auto_asset_management($id_gudang = 0){
    if (empty($_GET['term'])) exit ;
    $q = strtolower($_GET["term"]);
    if (get_magic_quotes_gpc()) $q = stripslashes($q);
    $items = $this->mmaster->auto_asset_management($id_gudang, $q);
    
    $result = array();
    foreach ($items as $key=>$value) {
//      if (strpos(strtolower($key), $q) !== false) {
        array_push($result, array("id"=>$value, "label"=>$key, "value" => strip_tags($key)));
//      }
      if (count($result) > 11)
        break;
    }
//    $this->debug($result);
    echo json_encode($result);
    die;
  }
  public function auto_gudang(){
    if (empty($_GET['term'])) exit ;
    $q = strtolower($_GET["term"]);
    if (get_magic_quotes_gpc()) $q = stripslashes($q);
    $items = $this->mmaster->auto_gudang($q);
    $result = array();
    foreach ($items as $key=>$value) {
      if (strpos(strtolower($key), $q) !== false) {
        array_push($result, array("id"=>$value, "label"=>$key, "value" => strip_tags($key)));
      }
      if (count($result) > 11)
        break;
    }
    echo json_encode($result);
    die;
  }
  public function auto_supplier(){
    if (empty($_GET['term'])) exit ;
    $q = strtolower($_GET["term"]);
    if (get_magic_quotes_gpc()) $q = stripslashes($q);
    $items = $this->mmaster->auto_supplier($q);
    $result = array();
    foreach ($items as $key=>$value) {
      if (strpos(strtolower($key), $q) !== false) {
        array_push($result, array("id"=>$value, "label"=>$key, "value" => strip_tags($key)));
      }
      if (count($result) > 11)
        break;
    }
    echo json_encode($result);
    die;
  }
  function add_row_asset_in(){
    $key = $this->input->post('no');
    $isi = array(
      $this->form_eksternal->form_autocomplate("asset[]", "id_asset[]", "asset_".$key, "id_asset_".$key, site_url("asset/auto-asset"), "", 0, $extra = "", $fungsi = "", $name_update = "", $id_update = ""),
      $this->form_eksternal->form_input('qty[]', $value = '', 'class="span3" id="qty_'.$key.'"'),
    );
    foreach($isi as $si){
      $sisip .= "<td>{$si}</td>";
    }
    print <<<EOD
    <tr id='tr_{$key}'>{$sisip}
      <td><a href='javascript:void(0)' class='remove-element' onclick='del_row_tambahan("tr_{$key}")' title='Remove' >Remove</a></td>
    </tr>
EOD;
    die;
  }
  public function outlet($id = 0){
    if($id <= 0){
      if($this->session->userdata("id") > 0)
        $id = $this->session->userdata("id");
    }
    $list = $this->mdev_checklist->get_milik($id);
    $this->template->title('Sistem', "Outlet");
    
    $view = "milik";
//    if($this->mobile_detect->isMobile()){
//      $view = "mobile/m-milik";
//    }
    
    $this->template->build($view, 
      array('message' => "",
            'url'     => base_url()."themes/srabon/",
            'data'    => $list,
            'title_table'    => "Outlet In Asset Management",
          ));
    $this->template
      ->set_layout('default')
      ->build($view);
  }
  function pengembalian_asset($id_asset_to_outlet){
      $detail = $this->global_models->get("d_asset_to_outlet", array('id_asset_to_outlet' => $id_asset_to_outlet));
      
       $kirim = array(
            "id_asset_to_outlet"            => $detail[0]->id_asset_to_outlet,
            "id_asset_gudang"               => $detail[0]->id_asset_gudang,
            "id_asset"                      => $detail[0]->id_asset,
            "tanggal"                       => date('Y-m-d'),
            "note"                          => "id outlet | ".$detail[0]->id_outlet,
           "qty"                            => "1",
           "status"                         => "2",
            "create_by_users"               => $this->session->userdata('id'),
            "create_date"                   => date("Y-m-d")
        );
        $id_asset_to_outlet = $this->global_models->insert("d_asset_record_items_gudang", $kirim);
        
       $delete_asset_to_outlet = $this->global_models->delete("d_asset_to_outlet", array("id_asset_to_outlet" => $detail[0]->id_asset_to_outlet));
        redirect ("asset/product-in-gudang/".$detail[0]->id_asset_gudang);
  }
  function management_outlet($id_outlet, $hal = 0, $pesan = "hal"){
    $outlet = $this->global_models->get("m_outlet", array('id_outlet' => $id_outlet));
    $detail = $this->global_models->get("d_asset_to_outlet", array('id_outlet' => $id_outlet));
    $this->template->build("management-outlet", 
      array('message'         => $pesan,
            'url'             => base_url()."themes/srabon/",
            'title_table'     => "Asset Outlet ".$outlet[0]->name,
            'outlet'          => $outlet,
            'detail'          => $detail,
          ));
    $this->template
      ->set_layout('default')
      ->build("management-outlet");
  }
  function add_management_outlet($id_outlet,$id_asset_to_outlet = 0){
    if($this->input->post(NULL)){
      $pst = $this->input->post(NULL);
      if($pst['id_detail']){
        $kirim = array(
            "kode"            => $pst['kode'],
            "id_asset_gudang" => $pst['id_gudang'],
            "id_asset"        => $pst['id_asset'],
            "id_outlet"       => $pst['id_outlet'],
            "tanggal"         => $pst['tanggal'],
            "note"            => $pst['note'],
            "update_by_users" => $this->session->userdata('id'),
        );
        $id_asset_to_outlet = $this->global_models->update("d_asset_to_outlet", array("id_asset_to_outlet" => $pst['id_detail']), $kirim);
        $record = array(
            "id_asset_gudang"     => $pst['id_gudang'],
            "id_asset"            => $pst['id_asset'],
            "tanggal"             => $pst['tanggal'],
            "qty"                 => -1,
            "status"              => 2,
            "update_by_users"     => $this->session->userdata('id'),
        );
        $id_asset_record_items_gudang = $this->global_models->update("d_asset_record_items_gudang", array("id_asset_to_outlet" => $pst['id_detail']), $record);
      
         if($id_asset_to_outlet){
          redirect ("asset/management-outlet/$id_outlet/list/suksess");
        }
        else{
          redirect ("asset/management-outlet/$id_outlet/list/filed");
        }
      }
      else{
        $kirim = array(
            "kode"            => $pst['kode'],
            "id_asset_gudang" => $pst['id_gudang'],
            "id_asset"        => $pst['id_asset'],
            "id_outlet"       => $pst['id_outlet'],
            "tanggal"         => $pst['tanggal'],
            "note"            => $pst['note'],
            "create_by_users" => $this->session->userdata('id'),
            "create_date"     => date("Y-m-d")
        );
        $id_asset_to_outlet = $this->global_models->insert("d_asset_to_outlet", $kirim);
        if($id_asset_to_outlet){
          $record = array(
              "id_asset_gudang"     => $pst['id_gudang'],
              "id_asset"            => $pst['id_asset'],
              "id_asset_to_outlet"  => $id_asset_to_outlet,
              "tanggal"             => $pst['tanggal'],
              "qty"                 => -1,
              "status"              => 2,
              "create_by_users"     => $this->session->userdata('id'),
              "create_date"         => date("Y-m-d")
          );
          $id_asset_record_items_gudang = $this->global_models->insert("d_asset_record_items_gudang", $record);
             if($id_asset_to_outlet){
          redirect ("asset/management-outlet/$id_outlet/list/suksess");
        }
        else{
          redirect ("asset/management-outlet/$id_outlet/list/filed");
        }
        }
      }
    }
    $outlet = $this->global_models->get("m_outlet", array('id_outlet' => $id_outlet));
    $gudang = $this->global_models->get_dropdown("m_asset_gudang", "id_asset_gudang", "name", TRUE);
    $detail = $this->global_models->get("d_asset_to_outlet", array("id_asset_to_outlet" => $id_asset_to_outlet));
    $this->template->build("add-management-outlet", 
      array('message'         => "",
            'url'             => base_url()."themes/srabon/",
            'title_table'     => "Asset Outlet ".$outlet[0]->name,
            'outlet'          => $outlet,
            'gudang'          => $gudang,
            'detail'          => $detail,
          ));
    $this->template
      ->set_layout('default')
      ->build("add-management-outlet");
  }
  
     public function delete_management_outlet($id_outlet,$id){
    if($this->global_models->delete("d_asset_to_outlet", array("id_asset_to_outlet" => $id)))
      redirect("asset/management-outlet/$id_outlet/list-delete");
    else
      redirect("asset/management-outlet/$id_outlet/list-delete/filed");
      
  }
  
    function log_asset_outlet($id_asset_to_outlet, $hal = 0, $pesan = "hal"){
            
    $asset_log = $this->global_models->get("d_asset_to_outlet", array('id_asset_to_outlet' => $id_asset_to_outlet));
    $asset_replace = $this->global_models->get("d_asset_to_outlet_replace", array('id_asset_to_outlet' => $id_asset_to_outlet));
    $outlet = $this->global_models->get("m_outlet", array('id_outlet' => $asset_log[0]->id_outlet));
    $detail = $this->global_models->get("d_asset_to_outlet_log", array('id_asset_to_outlet' => $id_asset_to_outlet));
    
    $this->template->build("log-asset-outlet", 
      array('message'         => $pesan,
            'url'             => base_url()."themes/srabon/",
            'title_table'     => "Log Asset Outlet ".$outlet[0]->name,
            'asset_log'          => $asset_log,
          'asset_replace'          => $asset_replace,
          'outlet'          => $outlet,
            'detail'          => $detail,
          ));
    $this->template
      ->set_layout('default')
      ->build("log-asset-outlet");
  }
  function add_log_asset_outlet($id_asset_to_outlet,$id_asset_to_outlet_log = 0){
    if($this->input->post(NULL)){
      $pst = $this->input->post(NULL);
      if($pst['id_detail']){
        $kirim = array(
            "id_asset_to_outlet" => $pst['id_asset_to_outlet'],
            "title" => $pst['title'],
            "kode"            => $pst['kode'],
            "tanggal"         => $pst['tanggal'],
            "note"            => $pst['note'],
            "update_by_users" => $this->session->userdata('id'),
        );
        $id_asset_to_outlet_log = $this->global_models->update("d_asset_to_outlet_log", array("id_asset_to_outlet_log" => $pst['id_detail']), $kirim);
         if($id_asset_to_outlet_log){
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list/suksess");
        }
        else{
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list/filed");
      }
        }
      else{
        $kirim = array(
            "id_asset_to_outlet" => $pst['id_asset_to_outlet'],
           "title" => $pst['title'],
            "kode"            => $pst['kode'],
            "tanggal"         => $pst['tanggal'],
            "note"            => $pst['note'],
            "create_by_users" => $this->session->userdata('id'),
            "create_date"     => date("Y-m-d")
        );
        $id_asset_to_outlet_log = $this->global_models->insert("d_asset_to_outlet_log", $kirim);
        if($id_asset_to_outlet_log){
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list/sukses");
        }
        else{
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list/filed");
      }
      }
    }
    $asset_log = $this->global_models->get("d_asset_to_outlet", array('id_asset_to_outlet' => $id_asset_to_outlet));
     $outlet = $this->global_models->get("m_outlet", array('id_outlet' => $asset_log[0]->id_outlet));
    $detail = $this->global_models->get("d_asset_to_outlet_log", array("id_asset_to_outlet_log" => $id_asset_to_outlet_log));
    $this->template->build("add-log-asset-outlet", 
      array('message'         => "",
            'url'             => base_url()."themes/srabon/",
            'title_table'     => "Log Asset Outlet ".$outlet[0]->name,
            'asset_log'          => $asset_log,
            'detail'          => $detail,
          ));
    $this->template
      ->set_layout('default')
      ->build("add-log-asset-outlet");
  }
    public function delete_log_asset_outlet($id_asset_to_outlet,$id){
    if($this->global_models->delete("d_asset_to_outlet_log", array("id_asset_to_outlet_log" => $id)))
      redirect("asset/log-asset-outlet/$id_asset_to_outlet/list-delete");
    else
      redirect("asset/log-asset-outlet/$id_asset_to_outlet/list-delete/filed");
      
  }
  
  function add_replace_asset_outlet($id_asset_to_outlet,$id_asset_to_outlet_replace = 0){
    if($this->input->post(NULL)){
      $pst = $this->input->post(NULL);
      if($pst['id_detail']){
        $kirim = array(
            "kode"            => $pst['kode'],
            "id_asset_gudang" => $pst['id_gudang'],
            "id_asset"        => $pst['id_asset'],
             "id_asset_to_outlet" => $pst['id_asset_to_outlet'],
            "tanggal"         => $pst['tanggal'],
            "note"            => $pst['note'],
            "update_by_users" => $this->session->userdata('id'),
        );
        $id_asset_to_outlet_replaca = $this->global_models->update("d_asset_to_outlet_replace", array("id_asset_to_outlet_replace" => $pst['id_detail']), $kirim);
            if($id_asset_to_outlet_replace){
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list-sukses");
        }
        else{
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list-filed");
      }
        }
      else{
        $kirim = array(
            "id_asset_to_outlet" => $pst['id_asset_to_outlet'],
           "kode"            => $pst['kode'],
            "id_asset_gudang" => $pst['id_gudang'],
            "id_asset"        => $pst['id_asset'],
            "tanggal"         => $pst['tanggal'],
            "note"            => $pst['note'],
            "create_by_users" => $this->session->userdata('id'),
            "create_date"     => date("Y-m-d")
        );
        $id_asset_to_outlet_replace = $this->global_models->insert("d_asset_to_outlet_replace", $kirim);
        if($id_asset_to_outlet_replace){
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list-sukses");
        }
        else{
          redirect ("asset/log-asset-outlet/$id_asset_to_outlet/list-filed");
      }
      }
    }
   // $outlet = $this->global_models->get("m_outlet", array('id_outlet' => $id_outlet));
    $gudang = $this->global_models->get_dropdown("m_asset_gudang", "id_asset_gudang", "name", TRUE);
   $asset_outlet = $this->global_models->get("d_asset_to_outlet", array('id_asset_to_outlet' => $id_asset_to_outlet));
   $outlet = $this->global_models->get("m_outlet", array('id_outlet' => $asset_log[0]->id_outlet));
    $detail = $this->global_models->get("d_asset_to_outlet_replace", array("id_asset_to_outlet_replace" => $id_asset_to_outlet_replace));
    $this->template->build("add-replace-outlet", 
      array('message'         => "",
            'url'             => base_url()."themes/srabon/",
            'title_table'     => "Log Asset Outlet ".$outlet[0]->name,
            'asset_outlet'          => $asset_outlet,
          'gudang'          => $gudang,
            'detail'          => $detail,
          ));
    $this->template
      ->set_layout('default')
      ->build("add-replace-outlet");
  }
  public function delete_replace_asset_outlet($id_asset_to_outlet,$id){
    if($this->global_models->delete("d_asset_to_outlet_replace", array("id_asset_to_outlet_replace" => $id)))
      redirect("asset/log-asset-outlet/$id_asset_to_outlet/list-delete");
    else
      redirect("asset/log-asset-outlet/$id_asset_to_outlet/list-delete/filed");
      
  }
}
  ?>